/**
 * Created by 银信数据科技 on 2018/2/27.
 */
import React from 'react';
import {connect} from 'dva';
import ProductList from '../../components/ProductList/ProductList'//引入模块
const Products = ({ dispatch, products }) => {//这两个参数从哪里来

  function handleDelete(id) {//点击删除的方法 id是
    dispatch({//redux里面的方法 派遣路径 id 点击事件返回
      type: 'products/delete',
      payload: id
    })
  };
  function handleChange(record){
    dispatch({
      type:'products/change',
      payload:record
    })
  }
  return (
    <div>
      <h2> ListofProducts </h2>
      <ProductList onDelete={handleDelete} onChange={handleChange} products={products}/>
    </div>
  )
};
export default connect(({products}) => ({//返回connect中的products出来 赋值给Products对象
  products
}))(Products);
